package com.wxc.thread;

import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author wxc
 * @date 2021年10月01日 19:05
 */
public class ManageConnectionThreads {
    private static final Map<String,ConnectionThread> map = new ConcurrentHashMap<>();

    public static void add(String username,ConnectionThread connectionThread) {
        map.put(username,connectionThread);
    }

    public static ConnectionThread get(String username) {
        return map.get(username);
    }

    public static void remove(String username) {
        map.remove(username);
    }

    public static Set<String> getUsernames() {
        return map.keySet();
    }

    public static boolean contain(String username) {
        return map.containsKey(username);
    }

    public static Collection<ConnectionThread> getValues() {
        return map.values();
    }
}
